Skip to content

Delete orphaned attachments#7513

Merged
labkey-adam merged 8 commits intodevelopfrom
fb_delete_orphans
Mar 26, 2026
Merged

Delete orphaned attachments#7513
labkey-adam merged 8 commits intodevelopfrom
fb_delete_orphans

Conversation

@labkey-adam
Copy link
Copy Markdown
Contributor

@labkey-adam labkey-adam commented Mar 22, 2026

Rationale

Deployments have orphaned attachments. For now, we'll give admins the ability to review and delete them, if they wish. In the future, once we've confirmed our orphan detection is correct, we'll likely add an update script that invokes this.

Tasks 📍

  • Dev
  • Code review @labkey-matthewb
  • Manual Testing / Verify Fix @DariaBod
    • Admin Console -> Attachments -> Click on any count to see details -> Customize Grid -> Show Hidden Fields -> Add "Orphaned" field -> Clear the ParentType filter -> Filter by Orphaned = True: you now have a list of all orphaned attachments in your server
    • If you don't have any orphaned attachments you can create some (on develop, as long as we haven't merged my fixes from 26.3) by:
    • Invoke the core.deleteOrphanedAttachments() upgrade code: Admin Console -> SQL Scripts -> Upgrade Code -> Select "Core: deleteOrphanedAttachments()" -> Invoke
    • Upgrade code should execute without errors and your orphaned attachment grid should now be empty
  • Needs Automation
  • User Education handoff? @labkey-adam

User Education

  • No documentation is needed
  • Services should be aware that orphaned attachments can be reviewed and deleted by an administrator via manual invocation of upgrade code (see steps above in the Manual Testing section)
    • In most cases, orphaned attachments represent coding issues, where LabKey has deleted an object in the system without deleted the associated attachments. These orphaned attachments take up space in the database but are unreachable. As an example, labkey.org has nearly 1GB of orphaned attachments.
    • Attachments will become orphaned if a module that handles attachments is removed from the deployment. This happened when we removed the ELN and Signing modules from labkey.org. (Though the majority of that 1GB is from older issues.)
    • In at least one case, our report flagged legitimate attachments as "orphaned" due to a problem with the report. This has been fixed, but it's possible there are other issues like this.
    • In all cases, we'd like to understand what caused orphaned attachments, to the extent that's possible.
    • At some point, once we're confident that our determination of orphaned attachments is correct, we'll delete all orphaned attachments at some upgrade

@labkey-adam labkey-adam self-assigned this Mar 22, 2026
@labkey-adam labkey-adam added this to the 26.04 milestone Mar 22, 2026
@labkey-adam labkey-adam merged commit cb2b140 into develop Mar 26, 2026
8 checks passed
@labkey-adam labkey-adam deleted the fb_delete_orphans branch March 26, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants